package com.nbsaas.boot.customer.rest.convert;

import com.nbsaas.boot.entity.customer.MemberProfile;
import com.nbsaas.boot.customer.api.domain.response.MemberProfileResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;
/**
* 会员-实体对象转化成响应对象
*/

public class MemberProfileResponseConvert  implements Converter<MemberProfileResponse,MemberProfile> {

    @Override
    public MemberProfileResponse convert(MemberProfile source) {
        MemberProfileResponse  result = new  MemberProfileResponse();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getCreator()!=null){
                        result.setCreator(source.getCreator().getId());
                    }
                    if(source.getHasChildren()!=null){
                    Map<Integer,String> HasChildrenMap=new HashMap<>();
                        HasChildrenMap.put(1,"有");
                        HasChildrenMap.put(0,"无");
                    String label=  HasChildrenMap.get(source.getHasChildren());
                    result.setHasChildrenName(label);
                    }
                    result.setHasChildren(source.getHasChildren());
                    if(source.getHasHouse()!=null){
                    Map<Integer,String> HasHouseMap=new HashMap<>();
                        HasHouseMap.put(1,"有");
                        HasHouseMap.put(0,"无");
                    String label=  HasHouseMap.get(source.getHasHouse());
                    result.setHasHouseName(label);
                    }
                    result.setHasHouse(source.getHasHouse());
                    if(source.getStoreState()!=null){
                        result.setStoreStateName(String.valueOf(source.getStoreState()));
                    }
                    if(source.getHasCar()!=null){
                    Map<Integer,String> HasCarMap=new HashMap<>();
                        HasCarMap.put(1,"有");
                        HasCarMap.put(0,"无");
                    String label=  HasCarMap.get(source.getHasCar());
                    result.setHasCarName(label);
                    }
                    result.setHasCar(source.getHasCar());
        return result;
    }

}

